import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import Login from '@/components/user/Login'
import Register from "@/components/user/Register";
import MovieList from '@/views/movie/MovieList'
import ActorList from "@/views/actor/ActorList"
import Actor from "@/views/actor/Actor.vue"
import CategoryList from "@/views/category/CategoryList"
import RecommendList from "@/views/movie/RecommendList"
import MovieAndActorList from "@/views/movie/MovieAndActorList"
import Movie from "@/views/movie/Movie"
import EditMovie from "@/views/movie/EditMovie";
import MoveAndActor from "@/views/movie/MoveAndActor"
import Welcome from "@/views/Welcome";
import EditActor from "@/views/actor/EditActor";
import EditMoveAndActor from "@/views/movie/EditMoveAndActor";
import SaveCategory from "@/views/category/SaveCategory.vue";

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const orginalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return orginalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        redirect: "/welcome",
        children: [
            {
                path: '/welcome',
                name: 'Welcome',
                component: Welcome
            },
            {
                path: '/movieList',
                name: 'MovieList',
                component: MovieList
            },
            {
                path: '/actorList',
                name: 'ActorList',
                component: ActorList
            },
            {
                path: '/actor',
                name: 'Actor',
                component: Actor
            },
            {
                path: '/editActor',
                name: 'EditActor',
                component: EditActor
            },
            {
                path: '/categoryList',
                name: 'CategoryList',
                component: CategoryList
            },
            {
                path: '/recommendList',
                name: 'RecommendList',
                component: RecommendList
            },
            {
                path: '/movieAndActorList',
                name: 'MovieAndActorList',
                component: MovieAndActorList
            },
            {
                path: '/movie',
                name: 'Movie',
                component: Movie
            },
            {
                path: '/editMovie',
                name: 'EditMovie',
                component: EditMovie
            },
            {
                path: '/moveAndActor',
                name: 'MoveAndActor',
                component: MoveAndActor
            },
            {
                path: '/editMoveAndActor',
                name: 'EditMoveAndActor',
                component: EditMoveAndActor
            },
            {
                path: '/categoryList',
                name: 'CategoryList',
                component: CategoryList
            },
            {
                path: '/saveCategory',
                name: 'SaveCategory',
                component: SaveCategory
            }

        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },


]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
